package com.jyw.router.hospital.domain.vo;

import com.jyw.router.hospital.domain.HospitalInfo;
import com.jyw.router.hospital.domain.HospitalRegisterUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * @author 沈峻
 * @ClassName RegisterUserVo
 * @Description TODO
 * @Date 2023/4/18 15:06
 **/
@ApiModel("用户注册信息")
@Data
public class RegisterUserVo {
    @ApiModelProperty("医院公钥")
    @NotBlank(message = "医院公钥不能为空")
    private String serverKey;

    @ApiModelProperty("医院私钥")
    @NotBlank(message = "医院私钥不能为空")
    private String serverSecret;

    @ApiModelProperty("用户手机号")
    @NotBlank(message = "用户手机号不能为空")
    private String userPhone;

    @ApiModelProperty("用户系统标识")
    @NotNull(message = "用户标识不能为空")
    private Long userId;

    public HospitalRegisterUser buildUser(HospitalInfo hospital) {
        HospitalRegisterUser user = new HospitalRegisterUser();
        user.setUserId(getUserId());
        user.setUserPhone(getUserPhone());
        user.setHospitalId(hospital.getId());
        user.setRecordState(0);
        user.setCreateTime(LocalDateTime.now());
        return user;
    }
}
